package com.lexue.articlesync.adapter;

import com.lexue.articlesync.entity.Article;
import com.lexue.articlesync.entity.Video;
import com.lexue.articlesync.entity.PlatformAuth;

/**
 * 平台发布适配器接口
 */
public interface PlatformAdapter {
    
    /**
     * 获取平台代码
     */
    String getPlatformCode();
    
    /**
     * 获取平台名称
     */
    String getPlatformName();
    
    /**
     * 验证认证信息是否有效
     */
    boolean validateAuth(PlatformAuth auth);
    
    /**
     * 刷新认证令牌
     */
    PlatformAuth refreshAuth(PlatformAuth auth);
    
    /**
     * 发布文章
     */
    PublishResult publishArticle(Article article, PlatformAuth auth, PublishOptions options);
    
    /**
     * 发布视频
     */
    PublishResult publishVideo(Video video, PlatformAuth auth, PublishOptions options);
    
    /**
     * 检查发布状态
     */
    PublishStatus checkPublishStatus(String platformContentId, PlatformAuth auth);
    
    /**
     * 删除已发布的内容
     */
    boolean deleteContent(String platformContentId, PlatformAuth auth);
    
    /**
     * 获取平台支持的内容类型
     */
    String[] getSupportedContentTypes();
    
    /**
     * 发布结果
     */
    class PublishResult {
        private boolean success;
        private String contentId;
        private String contentUrl;
        private String errorMessage;
        private Object rawResponse;
        
        public PublishResult(boolean success) {
            this.success = success;
        }
        
        public PublishResult(boolean success, String contentId, String contentUrl) {
            this.success = success;
            this.contentId = contentId;
            this.contentUrl = contentUrl;
        }
        
        public PublishResult(boolean success, String errorMessage) {
            this.success = success;
            this.errorMessage = errorMessage;
        }
        
        public PublishResult(boolean success, String contentId, String contentUrl, String errorMessage) {
            this.success = success;
            this.contentId = contentId;
            this.contentUrl = contentUrl;
            this.errorMessage = errorMessage;
        }
        
        // Getters and Setters
        public boolean isSuccess() { return success; }
        public void setSuccess(boolean success) { this.success = success; }
        
        public String getContentId() { return contentId; }
        public void setContentId(String contentId) { this.contentId = contentId; }
        
        public String getContentUrl() { return contentUrl; }
        public void setContentUrl(String contentUrl) { this.contentUrl = contentUrl; }
        
        public String getErrorMessage() { return errorMessage; }
        public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; }
        
        public Object getRawResponse() { return rawResponse; }
        public void setRawResponse(Object rawResponse) { this.rawResponse = rawResponse; }
    }
    
    /**
     * 发布选项
     */
    class PublishOptions {
        private String title;
        private String content;
        private String tags;
        private String coverImage;
        private boolean isOriginal = true;
        private boolean joinActivity = false;
        private String activityId;
        private boolean autoPublish = true;
        
        // Getters and Setters
        public String getTitle() { return title; }
        public void setTitle(String title) { this.title = title; }
        
        public String getContent() { return content; }
        public void setContent(String content) { this.content = content; }
        
        public String getTags() { return tags; }
        public void setTags(String tags) { this.tags = tags; }
        
        public String getCoverImage() { return coverImage; }
        public void setCoverImage(String coverImage) { this.coverImage = coverImage; }
        
        public boolean isOriginal() { return isOriginal; }
        public void setOriginal(boolean original) { isOriginal = original; }
        
        public boolean isJoinActivity() { return joinActivity; }
        public void setJoinActivity(boolean joinActivity) { this.joinActivity = joinActivity; }
        
        public String getActivityId() { return activityId; }
        public void setActivityId(String activityId) { this.activityId = activityId; }
        
        public boolean isAutoPublish() { return autoPublish; }
        public void setAutoPublish(boolean autoPublish) { this.autoPublish = autoPublish; }
    }
    
    /**
     * 发布状态
     */
    enum PublishStatus {
        PENDING,        // 待发布
        PROCESSING,     // 处理中
        SUCCESS,        // 发布成功
        FAILED,         // 发布失败
        REVIEWING       // 审核中
    }
}